#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int n, m;

int main() {
    vector<vector<int>> lr;
    cin >> n >> m;
    int l, r, num;
    for (int i = 0; i < m; i++) {
        vector<int> a;
        cin >> l >> r >> num;
        a.emplace_back(l);
        a.emplace_back(r);
        a.emplace_back(num);
        lr.emplace_back(a);
    }
    sort(lr.begin(), lr.end(),[](auto& a, auto& b){
        if(a[0] == b[0]) return a[1] < b[1];
        return a[0] < b[0];
    });
    bool seats[n+1] = {};

    return 0;
}

/* 
    intput:
    10 3
    1 4 2
    3 6 2
    10 10 1

    output:
    8
 */